package com.antler.smt.portal.service.impl;

import com.antler.smt.enums.ResultCodeEnum;
import com.antler.smt.portal.mapper.OrderInfoMapper;
import com.antler.smt.portal.mapper.UserInfoMapper;
import com.antler.smt.response.admin.GetUserListResp;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.ShowUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhangyi
 * @date 2018/4/27 10:33
 */
@Service
public class ShowUserServiceImpl implements ShowUserService {


    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;
    /**
     * 获取项目专员信息
     *
     * @param requirementId
     * @return
     */
    @Override
    public Result<GetUserListResp> getUserInfoByRequirementId(Long requirementId) {
        Result result = null;

        long userId = orderInfoMapper.getUserInfoByRequirementId(requirementId);

        GetUserListResp userInfo = userInfoMapper.getUserInfo(userId);

        if(userInfo != null) {
            result = new Result(userInfo);
        }else{
            result = new Result(ResultCodeEnum.APPEND_DATA_ERROR,"用户找不到！");
        }

        return result;
    }

    /**
     * 展示商务专员
     *
     * @param requirementId
     * @return
     */
    @Override
    public Result<GetUserListResp> getBusinessUserInfoByRequirementId(Long requirementId) {
        Result result = null;

        long userId = orderInfoMapper.getBusinessUserInfoByRequirementId(requirementId);

        GetUserListResp userInfo = userInfoMapper.getUserInfo(userId);

        if(userInfo != null) {
            result = new Result(userInfo);
        }else{
            result = new Result(ResultCodeEnum.APPEND_DATA_ERROR,"商务专员找不到！");
        }
        return result;
    }
}
